//
// Created by yewei on 2025/4/29.
//
#include <stdio.h>
#include <bits/stdc++.h>

#define n 4
int queen[n + 1];

void Show() {
    int i;
    printf("(");
    for (int i = 1; i <= n; i++) {
        printf("%d", queen[i]);
    }
    printf(")\n");
}

int Place(int j) {
    int i;
    for (int i = 1; i < j; i++) {
        //1
        if (queen[j] == queen[i] || abs(queen[j] - queen[i]) == (j - i)) {
            return 0;
        }
    }
    return 1; //2
}

void Nqueen(int j) {
    int i;
    for (i = 1; i <= n; i++) {
        queen[j] = i;
        if (Place(j)) { //3
            if (j == n) {
                Show();
            } else {
                Nqueen(j + 1); //4
            }
        }
    }
}

int main() {
    Nqueen(1);
    return 0;
}